package com.yhyvr.api.controller.store;

import com.yhyvr.api.handle.ApiData;
import com.yhyvr.api.service.store.ApiNewsService;
import com.yhyvr.api.tool.ViewFactory;
import com.yhyvr.pojo.req.api.ApiReqData;
import com.yhyvr.pojo.req.api.store.peoblem.ApiNewsDetailReq;
import com.yhyvr.pojo.req.api.store.peoblem.ApiNewsListReq;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by tech6 on 2016/10/11.
 * 官网接口
 */

@Controller
public class ApiIndexController{


    @Resource
    private ApiNewsService apiNewsService;

    @RequestMapping(value = {"/api/store/question/list"})
    public @ResponseBody ModelAndView newsList(@ApiData(tokenValidate = false) ApiReqData<ApiNewsListReq> apiReqDataApiReqData){
        return ViewFactory.buildApiJsonpView(apiNewsService.newsList(apiReqDataApiReqData),apiReqDataApiReqData.getCrossDomain());
    }


    @RequestMapping(value = {"/api/store/question/detail"})
    public @ResponseBody ModelAndView newsDetail(@ApiData(tokenValidate = false) ApiReqData<ApiNewsDetailReq> apiReqDataApiReqData){
        return ViewFactory.buildApiJsonpView(apiNewsService.newsDetail(apiReqDataApiReqData),apiReqDataApiReqData.getCrossDomain());
    }

}
